

from collections import deque

# 无重复字串

class Solution:

    def lengthOfLongestSubstring(self, s: str):
        
        n = len(s)
        if n <= 1:
            return n

        maxL = 0
        q = deque()
        for c in s:

            if c not in q:

                q.append(c)

            else:
                while q.popleft() != c:
                    continue

                q.append(c)


            maxL = max(maxL, len(q))

        return maxL



